# -*- coding: utf-8 -*-
from datetime import timedelta

from utils.operators.spark_submit import SparkSubmitOperator

from jms.dim.dim_lmdm_sys_network import jms_dim__dim_lmdm_sys_network
from jms.dwd.dwd_s03_barscan_operations_hist_dt import jms_dwd__dwd_s03_barscan_operations_hist_dt

out_days = 15  # 输出最近 15 天的分区
in_days = out_days + 8  # 读入最近 15 + 8 天的扫描数据
jms_dwd__dwd_s03_whole_operations_trace_rank_dt = SparkSubmitOperator(
    task_id='jms_dwd__dwd_s03_whole_operations_trace_rank_dt',
    pool_slots=16,
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='jms_dwd__dwd_s03_whole_operations_trace_rank_dt_{{ execution_date | date_add(1) | cst_ds }}',  # yarn 任务名称
    driver_memory='38G',
    driver_cores=12,
    executor_memory='28G',
    executor_cores=10,
    num_executors=200,
    email=['rongguangfan@jtexpress.com','yl_bigdata@yl-scm.com'],
    conf={'spark.executor.memoryOverhead': 3072,
          'spark.core.connection.ack.wait.timeout': 3000,
          'spark.default.parallelism': 9600,
          'spark.sql.shuffle.partitions': 9600,
          'spark.locality.wait': 60,
          'spark.network.timeout': 300,
          'spark.driver.maxResultSize': 20,
          },
    java_class='com.yunlu.bigdata.jobs.udaf.YlBarscanToTraceNew',  # spark 主类
    application='hdfs:///scheduler/jms/spark/sj/dwd_s03_whole_operations_trace_rank_dt/jobs-1.0-SNAPSHOT.jar',
    # spark jar 包
    application_args=['{{ execution_date | cst_ds }}', '29', '29'],
    # 参数dt 2020-10-26
    #execution_timeout=timedelta(hours=2)
    #excel平均时长:0
    execution_timeout = timedelta(minutes=30),
)

jms_dwd__dwd_s03_whole_operations_trace_rank_dt << [
    jms_dim__dim_lmdm_sys_network,
    jms_dwd__dwd_s03_barscan_operations_hist_dt
]
